﻿function OpenWindow(url, swidth, sheight) {
    //    if (navigator.appName == "Microsoft Internet Explorer") {
    //        var ReturnStr = showModalDialog(url, window, 'dialogWidth:' + swidth + 'pt;dialogHeight:' + sheight + 'pt;status:yes;help:no;scroll:yes;');
    //        if (ReturnStr != '' && ReturnStr != undefined) return ReturnStr;
    //    } else if (navigator.appName == "Netscape") {
    swidth += swidth * 0.4;
    sheight += sheight * 0.2;
    var objNewWin;
    var top = (screen.availHeight / 2) - (sheight / 2);
    var left = (screen.availWidth / 2) - (swidth / 2);

    if (isNaN(sheight)) {
        sheight = window.screen.height;
    }
    if (navigator.appName == "Microsoft Internet Explorer") {
        sheight = sheight - 100;
    }
    window.myAction = this;
    var objNewWin = window.open(url, '_blank', "dialog=yes,modal=yes,fullscreen=0,toolbar=0,location=no,directories=0,status=no,menubar=0,scrollbars=yes,resizable=yes,width=" + swidth + ",height=" + sheight + ",top=" + top + ",left=" + left, false);
    window.onclick = function() { objNewWin.focus() };
    //    }
    return objNewWin;
}

function Tab_t(n, m) {
    var m_n = document.getElementById("tab_" + n).getElementsByTagName("h4");
    for (var i = 0; i < m_n.length; i++) {
        m_n[i].className = i == m ? "current" : "";
        document.getElementById("tab_c_" + n + i).style.display = i == m ? "block" : "none";
    }
}


function initCity(obj) {
    $("#selectCity").empty();
    $("#selectCity").append("<option value='0'>--City--</option>");
    $("#selectCity").hide();
    $.getJSON("/handlers/RegionHandler.ashx" + "?t=c&v=" + obj.value, function (data) {
        if (data.contents.length > 0) {
            $.each(data.contents, function (i, item) {
                $("#selectCity").append("<option value='" + item.Key + "'>" + item.Value + "</option>");
            });
            $("#selectCity").show();
        }
    });
}
function initProvince(obj) {
    $("#selectProvince").empty();
    $("#selectProvince").append("<option value='0'>--Province--</option>");
    $("#selectProvince").hide();
    $("#selectCity").empty();
    $("#selectCity").hide();

    $.getJSON("/handlers/RegionHandler.ashx" + "?t=p&v=" + obj.value, function (data) {
        if (data.contents.length > 0) {
            $.each(data.contents, function (i, item) {
                $("#selectProvince").append("<option value='" + item.Key + "'>" + item.Value + "</option>");
            });
            $("#selectProvince").show();
            $("#selectCity").show();
            $("#selectCity").append("<option value='0'>--City--</option>");
        }
    });
}
function initRegion(ProvinceID, CityID, DistrictID) {
    $.ajaxSettings.async = false;
    if (ProvinceID) {
        $("#selectProvince").val(ProvinceID);
        var objPro = document.getElementById("selectProvince").options[window.document.getElementById("selectProvince").selectedIndex];
        initCity(objPro);
    }
    if (CityID) {
        $("#selectCity").val(CityID);
        var objCity = document.getElementById("selectCity").options[window.document.getElementById("selectCity").selectedIndex];
        initDistrict(objCity)
    }
    $.ajaxSettings.async = true
}